package com.elinkway.infinitemovies.widget;

import android.annotation.SuppressLint;
import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.widget.TextView;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

/**
 * Created by fuliqiang on 2017/4/19.
 */

@SuppressLint("AppCompatCustomView")
public class TimeView extends TextView {

    public static final String TIME_FORMAT_HH_MM = "HH:mm";

    public TimeView(Context context) {
        super(context);
        setTime();
    }

    public TimeView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        setTime();
    }

    public void setTime() {
        SimpleDateFormat formatter = new SimpleDateFormat(TIME_FORMAT_HH_MM, Locale.CHINESE);
        Date currentTime = new Date();
        this.setText(formatter.format(currentTime));
    }
}
